﻿Helper = function () {

    this.getParameterByName = function(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
    this.getCurrent = function(){
        $.ajax({
            url: 'SSEHandler.ashx',
            type: 'GET',
            dataType: "json",
            data: { method: 'getprofile' },
            success: function (json) {
                for (var i = 0; i < json.length; i++) {
                    $('#memberName').text(json[i].Email);
                    $('#point').text(json[i].Curent_Point);
                    $('#star').text(json[i].Curent_Star);
                }
            }
        });
    }
    this.returnImgResult = function(rollwin) {

        var imgrollwin = '';
        if (rollwin == 0) {
            imgrollwin += '<img src=/img/small/icon-draw.png alt="เสมอ 0 คะแนน" title="เสมอ 0 คะแนน">';
        } else if (rollwin == 1) {
            imgrollwin += '<img src=/img/small/icon-point-win-half.png alt="ได้ 1 คะแนน" title="ได้ 1 คะแนน">';
        } else if (rollwin == 2) {
            imgrollwin += '<img src=/img/small/icon-point-win-full.png alt="ได้ 2 คะแนน" title="ได้ 2 คะแนน">';
        } else if (rollwin == (-1)) {
            imgrollwin += '<img src=/img/small/icon-lost-half.png alt="เสีย -1 คะแนน" title="เสีย -1 คะแนน">';
        } else if (rollwin == (-2)) {
            imgrollwin += '<img src=/img/small/icon-lost-full.png alt="เสีย -2 คะแนน" title="เสีย -2 คะแนน">';
        }

        return imgrollwin;
    }
}